package com.example.mongodb.demo.utils;

import org.springframework.data.domain.Pageable;

public class DataUtils {

    public static long mongoSkipNum(long count, Pageable pageable){
        long skip = pageable.getPageNumber() == 1? 0: pageable.getPageSize() * pageable.getPageNumber() - pageable.getPageSize();
        skip = skip > count? count - count % pageable.getPageSize(): skip;
        return skip;
    }
}
